package compositeExpression;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import visitor.Visitor;
import exceptions.IllegalContextException;

public class Termb extends BooleanExpression {
	
	
	private List<Expression> factb ;
	
	
	public Termb(Expression factb){
		this.factb = new LinkedList();
		this.factb.add(factb);
		
	}

	@Override
	public void toAssess(String p) throws IllegalContextException {
		for (Expression fb : factb) {
            fb.toAssess(p);
        }
	}

	 public List<Expression> getState() {
	        
	        return factb;
	    }
	 
	 
	@Override
	public String toString() {
		 StringBuilder sb = new StringBuilder();
	        Iterator<Expression> it = factb.iterator(); 
	        sb.append(it.next());
	        while (it.hasNext()) {
	            
	            sb.append(" && ").append(it.next());
	            
	        }
	        return sb.toString();
	}

	@Override
    public void accept(Visitor v) {
        v.visit(this);
    }
	@Override
	public void add(Expression termb) {
		this.factb.add(termb);
	}

}
